/*
 * Copyright 2009-2011 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package br.com.ctm.advogadope.mobile;

import java.io.Serializable;

import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

import br.com.ctm.advogadope.negocio.api.ProcessoNegocio;
import br.jus.cnj.intercomunicacao.beans.ProcessoJudicial;

@Named
@ConversationScoped
public class ProcessoView implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String npu;

	private ProcessoJudicial processoJudicial;
	
	@Inject
	private ProcessoNegocio processoNegocio;
	
	@Inject
	private Conversation conversation;

	public ProcessoView() {
	}

	/**
	 * @return the npu
	 */
	public String getNpu() {
		return npu;
	}

	/**
	 * @param npu the npu to set
	 */
	public void setNpu(String npu) {
		this.npu = npu;
	}

	/**
	 * @return the processoJudicial
	 */
	public ProcessoJudicial getProcessoJudicial() {
		return processoJudicial;
	}

	/**
	 * @param processoJudicial the processoJudicial to set
	 */
	public void setProcessoJudicial(ProcessoJudicial processoJudicial) {
		this.processoJudicial = processoJudicial;
	}

	public String consultar() {
		processoJudicial = processoNegocio.buscarProcessoJudicial(npu, true, null);
		return "pm:main";
	}

	public String novaConsulta() {
		if (conversation.isTransient()) {
			conversation.begin();
		}
		npu = "";
		return "pm:new";
	}

}
